package com.aligotec.utils;

public class DateU {
	
	/**
	 * 
	 * @param date in format dd-mm-yyyy or dd/mm/yyyy
	 * @return String in format yyyy-mm-dd (for SQL)
	 */
	public static String toCorrectDate(String date){
		String[] sp = null;
		if(date.indexOf("/")>0){
			sp = date.split("/");
		}else if(date.indexOf("-")>0){
			sp = date.split("-");
		}
		if(sp != null && sp.length == 3){
			if(sp[0].length()>2){
				return sp[0] + "-" + sp[1] + "-" + sp[2]; 
			}else{
				return sp[2] + "-" + sp[1] + "-" + sp[0];
			}
		}
		return new String(date);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
